package com.jingtai.shop.webfacade.bo.shopcar;


import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.jingtai.common.webfacade.BaseBO;
import com.jingtai.common.webfacade.error.CommonException;
import com.jingtai.common.webfacade.error.ErrorEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;


import java.util.List;

/**
 * 用户删除购物车商品封装参数
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ShopCarRemoveBO extends BaseBO {

    /**
     * 商品ID与Sku code集合
     */
    private List<GoodsIdAndSkuBO> idAndSkuList;


    @Override
    public void validate() {
        super.validate();

        if (CollectionUtils.isEmpty(idAndSkuList)) {
            throw new CommonException(ErrorEnum.REQUIRED_PARAM_EMPTY);
        }

        idAndSkuList.forEach(GoodsIdAndSkuBO::validate);
    }
}
